function validateProbabilities(probabilities, isCommandLine) {
    const sum = probabilities.reduce((acc, val) => acc + parseFloat(val), 0);
    if (sum !== 1) {
      return false;
    }
    for (let i = 0; i < probabilities.length; i++) {
      const prob = parseFloat(probabilities[i]);
      if (prob < 0 || prob > 1) {
        return false;
      }
    }
    // 检查是否混合使用了逗号和空格分隔
    if (isCommandLine && /[,\s]/.test(probabilities.join('')) && /[\s,]/.test(probabilities.join(''))) {
      return false;
    }
    return true;
  }
  
  function calculateEntropy(probabilities) {
    return probabilities.reduce((acc, val) => {
      const prob = parseFloat(val);
      return acc - (prob * Math.log2(prob));
    }, 0);
  }
  
  module.exports = {
    validateProbabilities,
    calculateEntropy
  };